Skip to main content
This example demonstrates a complete privacy-preserving machine learning workflow using PVAC-HFHE. A credit scoring neural network evaluates loan applications on encrypted data, ensuring both the model and applicant data remain private.

Overview

The credit scoring system implements:
  • 8-input features: Age, income, debt, savings, credit history, employment, defaults, and open accounts
  • Hidden layer: 4 neurons with cubic activation (x³)
  • Output: Single risk score (negative = low risk, positive = high risk)
  • Fully homomorphic: All computations on encrypted data
This demonstrates PVAC-HFHE’s capability to run real machine learning models on encrypted data with verifiable computation.

Architecture

Model structure

Features

Decision logic

Implementation

1

Define the model structure

Create a simple MLP with 2-input hidden neurons:
The demo model:
2

Key generation with custom parameters

Use optimized parameters for ML workloads:
These reduced parameters enable fast demos. For production, use default parameters from Params constructor (m_bits=8192, lpn_n=4096).
3

Encrypt applicant features

Convert applicant data to encrypted feature vector:
4

Implement homomorphic inference

Evaluate the neural network on encrypted data:
5

Decrypt and interpret results

Convert encrypted score to decision:

Complete example

Sample data

The example includes a CSV dataset with test applicants:

Loading from CSV

Example output

Privacy guarantees

This implementation provides:
  1. Client privacy: Applicant features remain encrypted throughout evaluation
  2. Model privacy: Server can’t determine exact model weights from operations
  3. Verifiability: All computations can be verified using PVAC commitments
  4. No trusted party: Neither client nor server can cheat undetected

Workflow summary

1

Client: Generate keys

2

Client: Encrypt features

3

Server: Homomorphic inference

4

Client: Decrypt and decide

Performance characteristics

Circuit complexity

  • Depth: 496 layers (cubic activation creates depth-3 operations per neuron)
  • Size: ~4,500 edges per inference
  • Inference time: Fast with demo parameters, production parameters provide stronger security

Scaling to production

For production deployments:
For very fast production models, use the HFHE version over the OCTRA network for optimal performance.

Extending the model

Adding more neurons

Different activation functions

Multi-class output

Building and running

1

Build the example

2

Run with sample data

3

Use custom data

Create your own credit_db.csv with the same format and run again.

Source files

Complete source code:
  • examples/ml/credit_scoring.cpp - Main inference code
  • examples/ml/credit_db.csv - Sample applicant data
  • examples/ml/README.md - Additional documentation

Applications

This pattern extends to many privacy-preserving ML scenarios:
  • Healthcare: Diagnose patients without revealing medical records
  • Finance: Risk assessment with private financial data
  • Hiring: Candidate evaluation without bias or data exposure
  • Insurance: Premium calculation on encrypted claims history
  • Fraud detection: Pattern matching on encrypted transactions

Next steps

Basic usage

Learn PVAC-HFHE fundamentals

Polynomial evaluation

Understand activation functions

API reference

Explore all available functions

Core concepts

Understand the fundamentals